<template>
  <el-dialog title="上报属地错误" v-model="drawerVisible">
    <el-container>
      <el-main>
        <el-form
          :model="form"
          :rules="rules"
          ref="saveForm"
          label-width="100px"
        >
          <el-form-item label="企业名称" prop="name">
            {{ form.name }}
          </el-form-item>

          <el-form-item label="错误企业属地" prop="block">
            {{ form.block }}
          </el-form-item>

          <el-form-item label="正确企业属地" prop="blockIncorrect">
            <hh-dict
              v-model="form.blockIncorrect"
              dictType="block"
              placeholder="请选择正确企业属地"
              clearable
              filterable
            ></hh-dict>
          </el-form-item>
        </el-form>
      </el-main>
      <el-footer>
        <div class="form-footer">
          <el-button type="" @click="close">取消</el-button>
          <el-button type="primary" @click="submit">提交</el-button>
        </div>
      </el-footer>
    </el-container>
  </el-dialog>
</template>
  
  <script>
export default {
  name: "reportBlock-index",
  emits: ["success", "closed"],
  data() {
    return {
      drawerVisible: false,
      form: {
        enterpriseId: "",
        name: "",
        block: "",
        nature: "",
        finalBlock: "",
      },
      tips: "上报成功",
    };
  },
  watch: {
    $route(to, from) {
      if (to.fullPath != "/login") {
        this.getData();
      }
    },
  },
  mounted() {},
  methods: {
    //打开时
    open(id) {
      this.search.enterpriseId = id;
      this.search.orderData = "";
      this.search.sort = "";
      this.getData();
    },
    // 刷新
    onRefresh(form) {
      if (form) {
        Object.assign(this.search, form);
      }
      this.getData();
    },
    //修改
    async report(id, name, block) {
      this.drawerVisible = true;
      this.form.enterpriseId = id;
      this.form.name = name;
      this.form.block = block;
    },
    //提交
    submit() {
      this.$refs.saveForm.validate(async (valid) => {
        if (valid) {
          let res = await this.$API.notice.save.post(this.form);
          if (res.code == 0) {
            this.$message.success("上报错误属地成功");
            //调用父类刷新
            // this.$emit("onRefresh");
            this.drawerVisible = false;
          } else {
            let errdata = this.$TOOL.response(res);
            this.$alert(
              this.$TOOL.json.get("", errdata, "message"),
              this.$TOOL.json.get("", errdata, "title"),
              {
                type: "error",
                confirmButtonText: "确定",
                dangerouslyUseHTMLString: true,
                showCancelButton: false,
              }
            );
          }
        }
      });
    },
    // 关闭页面
    close() {
      this.drawerVisible = false;
    },
  },
};
</script>
  
  <style scoped>
</style>
  